<?php require_once('../Connections/parkwaydb_connection.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  $_SESSION['ParentID'] = NULL;
  unset($_SESSION['ParentID']);
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
	
  $logoutGoTo = "../index.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "1";
$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && false) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_newslist = 5;
$pageNum_newslist = 0;
if (isset($_GET['pageNum_newslist'])) {
  $pageNum_newslist = $_GET['pageNum_newslist'];
}
$startRow_newslist = $pageNum_newslist * $maxRows_newslist;

mysql_select_db($database_parkwaydb_connection, $parkwaydb_connection);
$query_newslist = "SELECT news_id, news_date, news_title FROM tbl_news ORDER BY news_date DESC";
$query_limit_newslist = sprintf("%s LIMIT %d, %d", $query_newslist, $startRow_newslist, $maxRows_newslist);
$newslist = mysql_query($query_limit_newslist, $parkwaydb_connection) or die(mysql_error());
$row_newslist = mysql_fetch_assoc($newslist);

if (isset($_GET['totalRows_newslist'])) {
  $totalRows_newslist = $_GET['totalRows_newslist'];
} else {
  $all_newslist = mysql_query($query_newslist);
  $totalRows_newslist = mysql_num_rows($all_newslist);
}
$totalPages_newslist = ceil($totalRows_newslist/$maxRows_newslist)-1;

$maxRows_rated_articles = 5;
$pageNum_rated_articles = 0;
if (isset($_GET['pageNum_rated_articles'])) {
  $pageNum_rated_articles = $_GET['pageNum_rated_articles'];
}
$startRow_rated_articles = $pageNum_rated_articles * $maxRows_rated_articles;

mysql_select_db($database_parkwaydb_connection, $parkwaydb_connection);
$query_rated_articles = "SELECT tbl_rating.id, tbl_rating.total_value, tbl_articles.articles_id, tbl_articles.articles_date, tbl_articles.articles_title FROM tbl_articles, tbl_rating WHERE tbl_rating.id = tbl_articles.articles_id ORDER BY tbl_rating.total_value DESC";
$query_limit_rated_articles = sprintf("%s LIMIT %d, %d", $query_rated_articles, $startRow_rated_articles, $maxRows_rated_articles);
$rated_articles = mysql_query($query_limit_rated_articles, $parkwaydb_connection) or die(mysql_error());
$row_rated_articles = mysql_fetch_assoc($rated_articles);

if (isset($_GET['totalRows_rated_articles'])) {
  $totalRows_rated_articles = $_GET['totalRows_rated_articles'];
} else {
  $all_rated_articles = mysql_query($query_rated_articles);
  $totalRows_rated_articles = mysql_num_rows($all_rated_articles);
}
$totalPages_rated_articles = ceil($totalRows_rated_articles/$maxRows_rated_articles)-1;

$maxRows_linkslist = 5;
$pageNum_linkslist = 0;
if (isset($_GET['pageNum_linkslist'])) {
  $pageNum_linkslist = $_GET['pageNum_linkslist'];
}
$startRow_linkslist = $pageNum_linkslist * $maxRows_linkslist;

mysql_select_db($database_parkwaydb_connection, $parkwaydb_connection);
$query_linkslist = "SELECT links_id, links_title, links_url FROM tbl_links ORDER BY links_id DESC";
$query_limit_linkslist = sprintf("%s LIMIT %d, %d", $query_linkslist, $startRow_linkslist, $maxRows_linkslist);
$linkslist = mysql_query($query_limit_linkslist, $parkwaydb_connection) or die(mysql_error());
$row_linkslist = mysql_fetch_assoc($linkslist);

if (isset($_GET['totalRows_linkslist'])) {
  $totalRows_linkslist = $_GET['totalRows_linkslist'];
} else {
  $all_linkslist = mysql_query($query_linkslist);
  $totalRows_linkslist = mysql_num_rows($all_linkslist);
}
$totalPages_linkslist = ceil($totalRows_linkslist/$maxRows_linkslist)-1;

$colname_user = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_user = $_SESSION['MM_Username'];
}
mysql_select_db($database_parkwaydb_connection, $parkwaydb_connection);
$query_user = sprintf("SELECT * FROM tbl_user WHERE username = %s", GetSQLValueString($colname_user, "text"));
$user = mysql_query($query_user, $parkwaydb_connection) or die(mysql_error());
$row_user = mysql_fetch_assoc($user);
$totalRows_user = mysql_num_rows($user);

mysql_select_db($database_parkwaydb_connection, $parkwaydb_connection);
$query_category_list = "SELECT * FROM tbl_category ORDER BY cat_title ASC";
$category_list = mysql_query($query_category_list, $parkwaydb_connection) or die(mysql_error());
$row_category_list = mysql_fetch_assoc($category_list);
$totalRows_category_list = mysql_num_rows($category_list);

$maxRows_view_links = 5;
$pageNum_view_links = 0;
if (isset($_GET['pageNum_view_links'])) {
  $pageNum_view_links = $_GET['pageNum_view_links'];
}
$startRow_view_links = $pageNum_view_links * $maxRows_view_links;

mysql_select_db($database_parkwaydb_connection, $parkwaydb_connection);
$query_view_links = "SELECT tbl_links.links_title, tbl_links.links_url, tbl_links.links_desc, tbl_category.cat_title, tbl_category.cat_desc, tbl_user.user_firstname, tbl_user.user_familyname, tbl_links.links_id FROM tbl_links, tbl_category, tbl_user WHERE tbl_links.fk_links_user_id=tbl_user.user_id ORDER BY links_title ASC";
$query_limit_view_links = sprintf("%s LIMIT %d, %d", $query_view_links, $startRow_view_links, $maxRows_view_links);
$view_links = mysql_query($query_limit_view_links, $parkwaydb_connection) or die(mysql_error());
$row_view_links = mysql_fetch_assoc($view_links);

if (isset($_GET['totalRows_view_links'])) {
  $totalRows_view_links = $_GET['totalRows_view_links'];
} else {
  $all_view_links = mysql_query($query_view_links);
  $totalRows_view_links = mysql_num_rows($all_view_links);
}
$totalPages_view_links = ceil($totalRows_view_links/$maxRows_view_links)-1;

$queryString_view_links = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_view_links") == false && 
        stristr($param, "totalRows_view_links") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_view_links = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_view_links = sprintf("&totalRows_view_links=%d%s", $totalRows_view_links, $queryString_view_links);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License

Name       : Arthropod  
Description: A two-column, fixed-width design with dark color scheme.
Version    : 1.0
Released   : 20100422

-->
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/site_template.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>The Parkway Child Care Centre and Beaumont Hills Longday Pre-school - ADMIN</title>
<link href="../js/jquery.alerts.css" rel="stylesheet" type="text/css" media="screen" />

<!-- InstanceEndEditable -->

<!-- CSS FILES -->
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
<link href="../css/style.css" rel="stylesheet" type="text/css" media="screen" />
<link href="../css/datepicker.css" rel="stylesheet" type="text/css" />

<!-- JAVASCRIPT RELATED FILES -->
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui.min.js"></script>
<script type="text/javascript" src="../js/mosaic.1.0.1.js"></script>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/datepicker.js"></script>
<script type="text/javascript" src="../js/eye.js"></script>
<script type="text/javascript" src="../js/utils.js"></script>

		
<script type="text/javascript">  
			
			jQuery(function($){
				
				$('.circle').mosaic({
					opacity		:	0.8			//Opacity for overlay (0-1)
				});
				
				$('.fade').mosaic();
				
				$('.bar').mosaic({
					animation	:	'slide'		//fade or slide
				});
				
				$('.bar2').mosaic({
					animation	:	'slide'		//fade or slide
				});
				
				$('.bar3').mosaic({
					animation	:	'slide',	//fade or slide
					anchor_y	:	'top'		//Vertical anchor position
				});
				
				$('.cover').mosaic({
					animation	:	'slide',	//fade or slide
					hover_x		:	'400px'		//Horizontal position on hover
				});
				
				$('.cover2').mosaic({
					animation	:	'slide',	//fade or slide
					anchor_y	:	'top',		//Vertical anchor position
					hover_y		:	'80px'		//Vertical position on hover
				});
				
				$('.cover3').mosaic({
					animation	:	'slide',	//fade or slide
					hover_x		:	'400px',	//Horizontal position on hover
					hover_y		:	'300px'		//Vertical position on hover
				});
		    
		    });
		    
		</script>
<!-- InstanceBeginEditable name="head" -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.js" type="text/javascript"></script>
<script src="../js/jquery.alerts.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){

    $("#dialog").dialog({
      modal: true,
            bgiframe: true,
            width: 500,
            height: 200,
      autoOpen: false
      });


    $(".confirmDelete").click(function(e) {
        e.preventDefault();
        var theHREF = $(this).attr("href");


        $("#dialog").dialog('option', 'buttons', {
                "Yes" : function() {
                    window.location.href = theHREF;
                    },
                "No" : function() {
                    $(this).dialog("close");
                    }
                });

        $("#dialog").dialog("open");

    });

});
</script>
<!-- InstanceEndEditable -->
</head>
<body>

<div id="wrapper">

    <div id="header">
        <div id="logo">
            <p><h4><a href="../index.php">Home</a> | <a href="../aboutus.php">About Us</a> | <a href="../contactus.php">Contact Us</a> | <img src="../images/administrator.png" width="16" height="16" alt="Admin" /><a href="index.php">Admin</a> &nbsp;<br /></h4></p>
            <p>
            <a href="javascript:decreaseFontSize()" class="nohover"><img src="../images/font-sizer-down.gif" alt="Decrease font size" width="25" height="25" border="0" /></a>
            <a href="javascript:increaseFontSize()" class="nohover"><img src="../images/font-sizer-up.gif" alt="Increase font size" width="25" height="25" border="0" /></a>
            </p>
        </div>
    </div>

  <div id="spacing"> <br /> </div>  
    
  <div id="menuboxes">
    <div class="mosaic-block bar2">
              <a href="../news.php" title="View Latest News" class="mosaic-overlay">
              <div class="details">
                <h4>News</h4> 
                <p>Check the latest news!</p>
              </div>
              </a>
            <div class="mosaic-backdrop"><img src="../images/1.jpg" width="190" height="200" alt="News"/></div>
        </div>
        <div class="mosaic-block bar2">
              <a href="../gallery.php" title="View the Gallery" class="mosaic-overlay">
              <div class="details">
                <h4>Gallery</h4>
                <p>View pictures</p>
              </div>
              </a>
              <div class="mosaic-backdrop"><img src="../images/2.jpg" width="190" height="200" alt="Gallery"/></div>
        </div>
        <div class="mosaic-block bar2">
              <a href="../linksarticles.php" title="View Articles and Links" class="mosaic-overlay">
              <div class="details">
                <h4>Articles and Links</h4>
                <p>Important articles and links</p>
              </div>
              </a>
              <div class="mosaic-backdrop"><img src="../images/3.jpg" width="190" height="200" alt="Articles and Links"/></div>
        </div>
        <div class="mosaic-block bar2">
              <a href="../staff.php" title="View Staff Information" class="mosaic-overlay">
              <div class="details">
                <h4>Staff</h4> 
                <p>Details on our Staff</p>
              </div>
              </a>
              <div class="mosaic-backdrop"><img src="../images/4.jpg" width="190" height="200" alt="Staff Information"/></div>
        </div>
      </div>

	
  <div id="spacing"> <br /> </div>  
    
  <div id="page">
		<div id="page-bgtop">
				<div id="content"><!-- InstanceBeginEditable name="main_region" -->
                
                <div id="dialog" title="Delete Link">
                	Are you sure you wish to delete this link?
                </div>
                
                
                
                
                
                <br />
                <div class="post">
                <h1 class="title">View Links</h1>
                <p class="meta">
                  This screen will list the links you currently have. <br />
                  Click <img src="../images/link_edit.png" alt="Edit Link" align="absmiddle" /> to edit that particular link.<br />
                  Click <img src="../images/link_delete.png" alt="Delete Link" align="absmiddle" /> to remove the link - please note, this will remove the link permanently!
                </p>
                <div style="clear: both;">&nbsp;</div>
                    <div class="entry">
		     <?php do { ?> 
                       	 <p>                   
                              <table width="100%" border="0" cellspacing="3" cellpadding="3" class="nohover">
                              <tr>
                                <td width="20%" valign="top"><strong>Link Title:</strong></td>
                                <td width="80%"><?php echo $row_view_links['links_title']; ?></td>
                              </tr>
                              <tr>
                                <td valign="top"><strong>Web Address:</strong></td>
                                <td><?php echo $row_view_links['links_url']; ?></td>
                              </tr>
                              <tr>
                                <td valign="top"><strong>Description:</strong></td>
                                <td><?php echo $row_view_links['links_desc']; ?></td>
                              </tr>
                              <tr>
                                <td valign="top"><strong>Category:</strong></td>
                                <td><?php echo $row_view_links['cat_title']; ?></td>
                              </tr>
                              <tr>
                                <td valign="top"><strong>Inserted By:</strong></td>
                                <td><?php echo $row_view_links['user_firstname']; ?> <?php echo $row_view_links['user_familyname']; ?></td>
                              </tr>
                              <tr>
                                <td colspan="2" class="meta">
                               	  <a href="admin_edit_link.php?links_id=<?php echo $row_view_links['links_id']; ?>" title="Edit Link">test<img src="../images/link_edit.png" alt="Edit Link" /></a> 
                                
                                  <a href="admin_delete_link.php?links_id=<?php echo $row_view_links['links_id']; ?>" title="Delete Link" class="confirmDelete"><img src="../images/link_delete.png" alt="Delete Link" id="confirmLinkClick" /></a> 
                                  <hr />
                                </td>
                                </tr>
                            </table>
                            
                            </p>
                        <?php } while ($row_view_links = mysql_fetch_assoc($view_links)); ?>
                       <p class="dbnav"> Records <?php echo ($startRow_view_links + 1) ?> to <?php echo min($startRow_view_links + $maxRows_view_links, $totalRows_view_links) ?> of <?php echo $totalRows_view_links ?></p>
                       <p class="dbnav"> 
                        <table border="0">
                          <tr>
                                                    <td><?php if ($pageNum_view_links > 0) { // Show if not first page ?>
                                                        <a href="<?php printf("%s?pageNum_view_links=%d%s", $currentPage, 0, $queryString_view_links); ?>" title="Jump to the first set" class="nohover"><img src="../images/resultset_first.png" alt="Jump to first set" /></a>
                            						    <?php } // Show if not first page ?>
                                                    </td>
                                                    <td><?php if ($pageNum_view_links > 0) { // Show if not first page ?>
                                                        <a href="<?php printf("%s?pageNum_view_links=%d%s", $currentPage, max(0, $pageNum_view_links - 1), $queryString_view_links); ?>" title="Go to previous set" class="nohover"><img src="../images/resultset_previous.png" alt="Go back to previous set" /></a>
                            							<?php } // Show if not first page ?>
                            						</td>
                                                    <td><?php if ($pageNum_view_links < $totalPages_view_links) { // Show if not last page ?>
                                                        <a href="<?php printf("%s?pageNum_view_links=%d%s", $currentPage, min($totalPages_view_links, $pageNum_view_links + 1), $queryString_view_links); ?>" title="Go to next set" class="nohover"><img src="../images/resultset_next.png" alt="Go to next set" /></a>
                            							<?php } // Show if not last page ?>
                                                    </td>
                                                    <td><?php if ($pageNum_view_links < $totalPages_view_links) { // Show if not last page ?>
                                                        <a href="<?php printf("%s?pageNum_view_links=%d%s", $currentPage, $totalPages_view_links, $queryString_view_links); ?>" title="Jump to the last set" class="nohover"><img src="../images/resultset_last.png" alt="Jump to the last set" /></a>
                                        				<?php } // Show if not last page ?>
                                        			</td>
                                      </tr>
                      </table>
                      </p>
                    </div> 
                </div>
                <!-- InstanceEndEditable --></div>
			<!-- end #content -->
            <div id="sidebar"><!-- InstanceBeginEditable name="sidebar_region" -->
        					<ul>
                            <li>
                              <h2>Administration</h2><p>Click <a href="<?php echo $logoutAction ?>">Logout</a> when finished</p> 
                              </li>
						<li>
					    <h2>Date</h2>
                            <ul>
                            <li><?php print(Date("jS M Y")); ?></li>
                            </ul>
						</li>
						<li>
							<h2>News</h2>
							<ul>
                              <?php do { ?>
                                <li><a href="../news.php?news_id=<?php echo $row_newslist['news_id']; ?>"><?php echo $row_newslist['news_title']; ?></a></li>
                                <?php } while ($row_newslist = mysql_fetch_assoc($newslist)); ?>
                            </ul>
						</li>
						<li>
							<h2>Articles</h2>
							<ul>
                              <?php do { ?>
                                <li><a href="../articles.php?articles_id=<?php echo $row_rated_articles['articles_id']; ?>"><?php echo $row_rated_articles['articles_title']; ?></a></li>
                                <?php } while ($row_rated_articles = mysql_fetch_assoc($rated_articles)); ?>
                            </ul>
						</li>
						<li>
							<h2>Links</h2>
							<ul>
								<?php do { ?>
								  <li><a href="<?php echo $row_linkslist['../links_url']; ?>"><?php echo $row_linkslist['links_title']; ?></a></li>
							    <?php } while ($row_linkslist = mysql_fetch_assoc($linkslist)); ?>
                          </ul>
						</li>
					</ul>

        
<!-- InstanceEndEditable --></div>
                    <!-- end #sidebar -->
			  <div style="clear: both;">&nbsp;</div>
		</div>
	</div>
	<!-- end #page -->
</div>

  <div id="spacing"> <br /> </div>  


<div id="footer">
	<p><a href="../index.php">Home</a> | <a href="../aboutus.php">About Us</a> | <a href="../contactus.php">Contact Us</a> | <a href="../news.php">News</a> | <a href="../gallery.php">Gallery</a> | <a href="../linksarticles.php">Links and Articles</a> | <a href="../staff.php">Staff</a> | <a href="index.php">Admin</a></p>
  <p>Copyright &copy; 2011 The Parkway Child Care Centre and Beaumont Hills Longday Pre-school. All rights reserved.<br />
Website Design by Igor Chuprov</p><br />
</div>
<!-- end #footer -->
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($newslist);

mysql_free_result($rated_articles);

mysql_free_result($linkslist);

mysql_free_result($user);

mysql_free_result($category_list);

mysql_free_result($view_links);
?>
